<?
namespace Api
{
/**
 *	Model parent. Class	define all
 *	communication methods.
**/
	abstract class	Model
	{
		protected $m_handle = null; 		// Handle to data object
		protected $m_config = array();		// Model config
		
		/* Return reference to handle object*/
		public function &GetHandle(){
			return $this->_handle;
		}
		
		public function __construct(array $config)
		{					
			if( is_array($config) )
			{	
				/** setup main model **/
				$this->m_config = $this->__initModel($config);
				/** loads others initalizers **/				
				foreach(get_class_methods($this) as $k => $v)
				{
					$matched = array();
					if(preg_match('/__init(.*)/',$v,$matched))
					{
						if($matched[1]!='Model') $this->$matched[0]($config);							
					}
					
					
				}
			}
		}
		
		public function GetConfig(){
			return $this->m_config;
		}
		
		abstract public function __initModel($config);
	}
}
?>